package com.dkh.recommend.controller;

import com.dkh.recommend.dto.BlogUploadDTO;
import com.dkh.recommend.dto.Result;
import com.dkh.recommend.service.TbBlogImgUrlService;
import com.dkh.recommend.service.TbBlogService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@Api(value = "音乐故事", tags = "音乐故事-相关", description="音乐故事-相关")
@RequestMapping("blog")
public class TbBlogController {

    @Resource
    private TbBlogService blogService;
//    @Resource
//    private TbBlogImgUrlService blogImgUrlService;

//    发布音乐故事
    @PostMapping("/uploadblog")
    public Result UploadBlog(@RequestBody BlogUploadDTO blogUploadDTO){
        return blogService.UploadBlog(blogUploadDTO);
    }
//     分页获取blog故事（根据浏览量倒序排序）
//    分页返回音乐列表：
    @GetMapping("/allblog/{pageNumber}/{pageSize}")
    public Result GetAllBlog(@PathVariable int pageNumber,@PathVariable int pageSize){
        return blogService.GetAllBlog(pageNumber,pageSize);
    //        return null;
    }
//    根据blogId 查看blog故事详情(看一次浏览量+1)
    @GetMapping("/allinfo")
    public Result GetAllInfoById(@RequestParam(value = "blogId") String blogId){
        return blogService.GetAllInfoById(blogId);
        //        return null;
    }

//    根据音乐id获取blog的音乐故事（浏览量倒序排序）
        @GetMapping("/bymusicid/{pageNumber}/{pageSize}")
        public Result GetAllByMusicId(@RequestParam(value = "musicId") String musicId ,@PathVariable int pageNumber,@PathVariable int pageSize){
            return blogService.GetAllByMusicId(musicId,pageNumber,pageSize);
            //        return null;
        }

    //    根据音乐id获取blog的音乐故事（浏览量倒序排序）
    @GetMapping("/byuserid/{pageNumber}/{pageSize}")
    public Result GetAllByUserId(@RequestParam(value = "userId") String userId ,@PathVariable int pageNumber,@PathVariable int pageSize){
        return blogService.GetAllByUserId(userId,pageNumber,pageSize);
        //        return null;
    }
//        根据blog_author获取blog列表
        @GetMapping("/byauthor")
        public Result GetAllByAuthorId(@RequestParam(value = "blogAuthor") String blogAuthor){
            return blogService.GetAllByAuthorId(blogAuthor);
            //        return null;
        }

//     获取blogimgUrlList
        @GetMapping("/blogimglist")
        public Result GetBlogImgList(@RequestParam(value = "blogId") String blogId){
//            return blogImgUrlService.GetBlogImgList(blogId);
            return blogService.GetBlogImgList(blogId);
            //        return null;
        }

}
